<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<% String path = request.getContextPath(); %>
<html>
<head>
    <title>个人信息</title>
    <link rel="icon" href="<%=path%>/images/favicon.ico" sizes="32x32" />
    <link rel="stylesheet" href="<%=path%>/css/font.css">
    <link rel="stylesheet" href="<%=path%>/css/xadmin.css">
    <link rel="stylesheet" href="<%=path%>/css/pg_btn.css">
    <script type="text/javascript" src="<%=path%>/js/jquery-1.3.2.min.js"></script>
    <script src="<%=path%>/lib/layui/layui.js"></script>
    <script type="text/javascript" src="<%=path%>/js/xadmin.js"></script>
</head>
<body>
<div class="x-body">
    <form class="layui-form"  id="f_auto" onsubmit="return false" action="##" method="post" >
        <input type="hidden" value="${sessionScope.ad.id}" name="id" id="id"/>

        <div class="layui-form-item">
            <label for="username" class="layui-form-label">
                <span class="">用户名</span>
            </label>
            <div class="layui-input-inline">
                <input type="text" id="username1" name="username"  disabled
                       autocomplete="off" value="${sessionScope.ad.username}" class="layui-input">
                <input type="hidden" id="username" name="username"  value="${sessionScope.ad.username}" class="layui-input">
            </div>
        </div>

        <c:if test="${sessionScope.type == '02'}">
            <div class="layui-form-item">
                <label for="phone" class="layui-form-label">
                    <span class="">电话</span>
                </label>
                <div class="layui-input-inline">
                    <input type="text" id="phone" name="phone"
                           autocomplete="off" value="${sessionScope.ad.phone}" class="layui-input">
                </div>
            </div>


        </c:if>

        <c:if test="${sessionScope.type == '03'}">
            <div class="layui-form-item">
                <label for="phone" class="layui-form-label">
                    <span class="">姓名</span>
                </label>
                <div class="layui-input-inline">
                    <input type="text" id="realname" name="realname"
                           autocomplete="off" value="${sessionScope.ad.realname}" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label for="phone" class="layui-form-label">
                    <span class="">性别</span>
                </label>
                <div class="layui-input-inline">
                    <input type="text" id="sex" name="sex"
                           autocomplete="off" value="${sessionScope.ad.sex}" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label for="phone" class="layui-form-label">
                    <span class="">手机号</span>
                </label>
                <div class="layui-input-inline">
                    <input type="text" name="phone" id="phone"
                           autocomplete="off" value="${sessionScope.ad.phone}" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label for="phone" class="layui-form-label">
                    <span class="">身份证号</span>
                </label>
                <div class="layui-input-inline">
                    <input type="text" name="idcard" id="idcard"
                           autocomplete="off" value="${sessionScope.ad.idcard}" class="layui-input">
                </div>
            </div>

            <div class="layui-form-item">
                <label for="phone" class="layui-form-label">
                    <span class="">所属社区</span>
                </label>
                <div class="layui-input-inline">
                    <input type="text" name="community"
                           autocomplete="off" value="${sessionScope.ad.community}" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label for="phone" class="layui-form-label">
                    <span class="">目前住址</span>
                </label>
                <div class="layui-input-inline">
                    <textarea name="address" id="address" placeholder="请输入内容"  class="layui-input">${sessionScope.ad.address}</textarea>
                </div>
            </div>
            <div class="layui-form-item">
                <label for="phone" class="layui-form-label">
                    <span class="">户籍所在地</span>
                </label>
                <div class="layui-input-inline">
                    <textarea name="place" id="place" lay-verify="required" placeholder="请输入内容"  class="layui-input">${sessionScope.ad.place}</textarea>
                </div>
            </div>
        </c:if>
        <div class="layui-form-item">
            <label for="password" class="layui-form-label">
                <span class="">原密码</span>
            </label>
            <div class="layui-input-inline">
                <input type="password" id="password" name="password"
                       autocomplete="off" value="" class="layui-input">
            </div>
        </div>

        <div class="layui-form-item">
            <label for="passwords" class="layui-form-label">
                <span class="">修改后密码</span>
            </label>
            <div class="layui-input-inline">
                <input type="password" id="passwords" name="passwords"
                       autocomplete="off" value="" class="layui-input">
            </div>
        </div>


        <div class="layui-form-item" style="margin-left: 131px;" id="btn_xg">
            <button  class="layui-btn" onclick="sub()">修改</button>
            <button  class="layui-btn" onclick="x_admin_close()">关闭</button>
        </div>
    </form>
</div>
<script>
    $('#close').click(function() {
        //window.location.href='/findBook';
        return false;
    });
    function sub() {
        $.ajax({
            type: "POST",//方法类型
            dataType: "json",//预期服务器返回的数据类型
            url: "<%=path%>/updateInfoAdmin" ,//url
            data: $('#f_auto').serialize(),
            success: function (result) {
                if (result == 202) {
                    layer.msg('用户身份过期，请重新登录', {icon: 2, time: 3000});
                };
                if (result == 201) {
                    layer.msg('原密码错误', {icon: 2, time: 3000});
                };
                if (result == 200) {
                    layer.msg('修改成功，请退出后重新登录', {icon: 1, time: 3000});
                };
                if (result == 204) {
                    layer.msg('原密码不能为空', {icon: 2, time: 3000});
                };
                if (result == 203) {
                    layer.msg('用户名不能为空', {icon: 2, time: 3000});
                };
                if (result == 205) {
                    layer.msg('手机号格式错误', {icon: 2, time: 3000});
                };
                if (result == 206) {
                    layer.msg('身份证号格式错误', {icon: 2, time: 3000});
                };
            },
            error : function() {
                alert("异常！");
            }
        });
    }

</script>
</body>
</html>